package com.zlm.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 工作类型
 * @Author: duyufu
 * @Date: 2019/5/15 14:53
 */
public enum WorkTypeEnum {

    WORK_TYPE_FULL_TIME(0,"全职"),
    WORK_TYPE_HOURLY(1,"小时工"),
    WORK_TYPE_VACATION(2,"寒暑假工"),
    WORK_TYPE_PRACTICE(3,"实习生");

    private Integer code;
    private String name;

    private WorkTypeEnum(Integer code,String name){
        this.code=code;
        this.name=name;
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static List getWorkType(){
        List list = new ArrayList();
        Map<String,Object> map;
        for(WorkTypeEnum workTypeEnum:WorkTypeEnum.values()){
            map= new HashMap<String, Object>();
            map.put("code", workTypeEnum.getCode());
            map.put("name", workTypeEnum.getName());
            list.add(map);
        }
        return list;
    }

    /**
     * 根据code得到name
     * @param code
     * @return
     */
    public static String getNameByCode(Integer code){
        for(WorkTypeEnum workTypeEnum:WorkTypeEnum.values()){
            if(code.equals(workTypeEnum.getCode())){
                return workTypeEnum.getName();
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
